<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>红包活动</title>
		<link rel="stylesheet" href="__AGENT__/css/iconfont.css" />
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
	</head>

	<body>
		{include file="public/header" /}
		<div class="index_conbox">
			<div class="index_content clearfix">
				{include file="public/lefter" /}
				<div class="right"><!--右侧内容-->
					<div class="rigtop">
						<span class="title">红包活动</span>
					</div>
					<div class="indrig_con" style="position: relative;">
						<div class="zizh_btnbox" style="top: -58px;right: 20px;">
							<button class="zizh_btn" type="button" onclick="gold_add()"><i class="iconfont icon-jia"></i>创建红包</button>
						</div>
						<div class="zizh_conbox" style="padding-top: 20px;">
						<!--选项卡内容开始-->
							<div class="chax_conbox">
								<div class="chax_jiegnr">
									<table class="zizh_table1 zizh_table2">
										<thead style="text-align: center;">
											<tr>
												<th class="w_10">编号</th>
												<th class="w_10">二维码</th>
												<th class="w_10">红包类型</th>
												<th class="w_10">人数</th>
												<th>所属员工编号</th>
												<th class="w_10">鼓励金总额</th>
												<th class="w_10">领取规则</th>
												<th class="w_10">创建时间</th>
												<th class="w_20">操作</th>
											</tr>
										</thead>
										<tbody id="tbody" style="text-align: center;">
											{volist name="list" id="vo" }
											<tr>							
												<td>{$vo.id}</td>
												<td><a class="iconfont icon-erweima"  href="javascript:;" onclick="gold_emm('{$vo.id}','{$vo.type}')"></a></td>									
												<td>
													{if $vo.type==1}
													锁粉红包
													{elseif $vo.type==3}
													扫码红包
													{/if}
												</td>
												<td>{$vo.user_num}</td>
												<td>{$vo.no}</td>
												<td>{$vo.gold_sum}</td>
												<td>
													{if $vo.hb_type==1}
													平均
													{else/}
													随机
													{/if}
												</td>
												<td>{$vo.add_time}</td>
												<td>
													<a onclick="gold_zj('{$vo.id}')" style="margin-top: 2px;">追加</a>
													<a onclick="gold_info('{$vo.id}')" style="margin-top: 2px;">详情</a>
													<a onclick="gold_log('{$vo.id}')" style="margin-top: 2px;">记录</a>
													<a onclick="gold_update('{$vo.id}')" style="margin-top: 2px;">编辑员工id</a>
													{if $vo.state==1}
													<a onclick="gold_close('{$vo.id}')" style="margin-top: 2px;">关闭</a>
													{/if}
												</td>
											</tr>
											{/volist}
										</tbody>
									</table>
									<div class="fenye" style="display: block;">
										<ul class="pagination">
											{$list->render()}
										</ul>
									</div>
								</div>
							</div>
						</div>
					</div>

					</div>
				</div>
			</div>
		</div>
		{include file="public/footer" /}
		<script>
			//追加红包
			function gold_zj(gold_id) {
				var url = 'gold_zj?gold_id='+gold_id;
				layer.open({
				  type: 2,
				  title: '追加红包活动',
				  shadeClose: true,
				  shade: 0.8,
				  area: ['500px', '450px'],
				  content: [url]
				}); 
			}
		
			//扫码领红包
			function gold_emm(gold_id,type) {
				if(type==1){
					var url = 'xsmfk?gold_id='+gold_id;
				}else{
					var url = 'smfk?gold_id='+gold_id;	
				}
				
				layer.open({
				  type: 2,
				  title: '扫码领红包',
				  shadeClose: true,
				  shade: 0.8,
				  area: ['426px', '678px'],
				  content: [url]
				}); 

			}
		
			//创建红包
			function gold_add() {
				layer.open({
				  type: 2,
				  title: '创建红包活动',
				  shadeClose: true,
				  shade: 0.8,
				  area: ['550px', '500px'],
				  content: "{:url('activet/gold_add')}"
				}); 
			}
			
			//红包详情
			function gold_info(gold_id) {
				var url = 'gold_info?gold_id='+gold_id;
				layer.open({
				  type: 2,
				  title: '红包详情',
				  shadeClose: true,
				  shade: 0.8,
				  area: ['500px', '500px'],
				  content: [url]
				}); 
			}
			
			function gold_log(gold_id) {
				var url = 'gold_log?gold_id='+gold_id;
				layer.open({
				  type: 2,
				  title: '红包领取记录',
				  shadeClose: true,
				  shade: 0.8,
				  area: ['600px', '450px'],
				  content: [url]
				}); 
			}
			//删除红包
			function gold_close(id) {
				layer.confirm('关闭红包会退回未被领取的红包同时重置红包！您确定关闭？', {
					btn: ['确定', '取消'] //按钮
				}, function() {
					$.ajax({
						url: "{:url('activet/gold_close')}",
						data: {
							id:id,
						},
						success: function(data) {
							layer.msg(data.msg, {
								  icon: 1,
								  time: 1500 //2秒关闭（如果不配置，默认是3秒）
								}, function(){
									location.href = "{:url('activet/gold_active')}";
								});
						}
					})
				})
			}
			
			/*操作*/
			function caozuo(id,status) {
				var msg='';
				if(status==2){
					msg='关闭';
				}else{
					msg='开启';
				}
				layer.confirm('您确定要'+msg+'吗？', {
					btn: ['确定', '取消'] //按钮
				}, function() {
					$.ajax({
						url: "{:url('activet/gold_status')}",
						data: {
							id:id,
							status:status
						},
						dataType: 'json',
						success: function(data) {
							layer.msg("成功", {
								icon: 1,
								time: 1000
							}, function() {
								location.href = "{:url('activet/gold_active')}";
							});
						}
					})
				})
			}
			
			function gold_update(id){
				layer.open({
				  type: 2,
				  title: '编辑员工id',
				  shadeClose: true,
				  shade: 0.8,
				  area: ['550px', '350px'],
				  content: "{:url('/agent/activet/gold_update/id/"+id+"')}"
				}); 
			}
		</script>
	</body>

</html>